﻿using System;
using System.Collections.Generic;
using CodeGenerator.interfaces;

namespace CodeGenerator.Implementations
{
    public class UniqueConstraint : IUniqueConstraint
    {
        private readonly IList<IDatabaseColumn> _columns;
        private readonly string _constraintName;
        private string _SignatureHash = "";
        public UniqueConstraint(string ConstraintName, IList<IDatabaseColumn> Columns)
        {
            _columns = Columns;
            _constraintName = ConstraintName;
            CreateSignature();
        }

        private void CreateSignature()
        {
            foreach (IDatabaseColumn c in _columns)
            {
                _SignatureHash += c.DataType.Name;
            }
            
        }

        public IList<IDatabaseColumn> Columns
        {
            get { return _columns; }
        }

        public string ConstraintName
        {
            get { return _constraintName; }
        }

        public string GetSignatureHash
        {
            get { return _SignatureHash; }
        }
    }
}